import { alovaInstance } from '@/utils/http'

export interface LoginParams {
  username: string
  password: string
}
export interface LoginResult {
  token: string
}
export function login(data: LoginParams) {
  return alovaInstance.Post<LoginResult>('auth/login', data, {
    meta: {
      authRole: 'login',
    },
  })
}

export function timeout() {
  return alovaInstance.Get('auth/timeout')
}

export interface MenuItem {
  id: string
  title: string
  icon: string
  path: string
  children?: MenuItem[]
}

export function menus() {
  return alovaInstance.Get<{
    menus: MenuItem[]
  }>('auth/menus')
}
